﻿#pragma once

#include "core/Macro.h"
#include "function/WindowSystem/AbstractWindow.h"
#include "function/RenderSystem/AbstractRenderContext.h"

#include <glad/glad.h>
#include <GLFW/glfw3.h>

namespace Engine
{
	/**
	 * Windows平台窗口，实现抽象窗口
	 */
	class ENGINE_API WindowsWindow final : public AbstractWindow
	{
	public:
		explicit WindowsWindow(const WindowProps& props);
		virtual ~WindowsWindow() override;

		void OnUpdate() override;

		inline void SetEventCallback(const EventCallBack& callback) override { data.Callback = callback; }
		void SetVSync(bool enable) override;
		inline bool IsVSync() const override { return data.VSync; }

		inline unsigned int GetWidth() const override { return data.Width; }
		inline unsigned int GetHeight() const override { return data.Height; }

		inline bool ShouldClose() const override { return glfwWindowShouldClose(window); }

		inline virtual void* GetNativeWindow() const override { return window; }

		void SetWindowTitle(const char* title) override { glfwSetWindowTitle(window, title); }

	private:
		GLFWwindow* window;
		AbstractRenderContext* renderContext;

		struct WindowData
		{
			std::string Title;
			unsigned int Width;
			unsigned int Height;
			bool VSync;

			EventCallBack Callback;
		};

		WindowData data;
	};
}
